/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package iterators;
import IA.Server;
import java.util.*;
/**
 *
 * @author Jeremy
 */
public class ShortestWorkloadServerItr implements Iterator<Server> {
    private ArrayList<Server> _servers;
    public ShortestWorkloadServerItr(ArrayList<Server> servers) {
        //clone original list
        _servers = (ArrayList<Server>)servers.clone();
        //sort them by shortest work load first
        Collections.sort(_servers,Server.getShortestWorkloadComparator());
    }
    
    @Override
    public boolean hasNext() {
        return !_servers.isEmpty();
    }

    @Override
    public Server next() {
        return _servers.remove(0);
    }

    @Override
    public void remove() {
       
    }
    
}
